package org.obp.oss.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 图片文件格式枚举
 */
@Getter
public enum FileSuffixEnum {

    jpg("jpg", "image/jpeg", "assets/img/"),
    bmp("bmp", "application/x-bmp", "assets/img/"),
    gif("gif", "image/gif", "assets/img/"),
    jpeg("jpeg", "image/jpeg", "assets/img/"),
    jpeg2000("jpeg2000", "image/jpeg", "assets/img/"),
    tiff("tiff", "image/tiff", "assets/img/"),
    psd("psd", "image/jpeg", "assets/img/"),
    png("png", "image/jpeg", "assets/img/"),
    swf("swf", "application/x-shockwave-flash", "assets/img/"),
    svg("svg", "application/x-shockwave-flash", "assets/img/"),
    pcx("pcx", "application/x-pcx", "assets/img/"),
    dxf("dxf", "application/x-dxf", "assets/img/"),
    wmf("wmf", "application/x-wmf", "assets/img/"),
    emf("emf", "application/x-emf", "assets/img/"),
    flc("flc", "image/jpeg", "assets/img/"),
    eps("eps", "application/x-ps", "assets/img/"),
    tga("tga", "application/x-tga", "assets/img/");

    /**
     * 后缀
     */
    private final String suffix;
    /**
     * http content_type
     */
    private final String contentType;
    /**
     * oss文件上传路径
     */
    private final String ossUploadPath;

    FileSuffixEnum(String suffix, String contentType, String ossUploadPath) {
        this.suffix = suffix;
        this.contentType = contentType;
        this.ossUploadPath = ossUploadPath;
    }

    public static FileSuffixEnum getFileSuffixEnum(String suffix) {
        if (Objects.isNull(suffix)) {
            return null;
        }
        for (FileSuffixEnum fileSuffixEnum : FileSuffixEnum.values()) {
            if (fileSuffixEnum.getSuffix().equals(suffix.toLowerCase())) {
                return fileSuffixEnum;
            }
        }
        return null;
    }

}
